﻿using GammaJul.ReSharper.GammaXaml.Highlightings.Xaml;
using GammaJul.ReSharper.GammaXaml.Psi.Xaml;
using JetBrains.ReSharper.Daemon.Stages;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Tree;

namespace GammaJul.ReSharper.GammaXaml.Analysis.Xaml {

	/// <summary>
	/// An analyzer that add highlightings for Caliburn gutter marks.
	/// </summary>
	public class CaliburnAnalysis : XamlAnalysis {

		public override void ProcessBeforeInterior(ITreeNode element, IHighlightingConsumer highlightings) {
			var reference = element.FindReference<CaliburnBoundXamlReference>();
			if (reference == null || reference is CaliburnGuardBoundXamlReference)
				return;

			IDeclaredElement declaredElement = reference.Resolve().DeclaredElement;
			if (declaredElement is IProperty)
				highlightings.AddHighlighting(new CaliburnPropertyBoundMarkOnGutter(element, reference), XamlFile);
			else if (declaredElement is IMethod)
				highlightings.AddHighlighting(new CaliburnMethodBoundMarkOnGutter(element, reference), XamlFile);
		}

	}

}